/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 21 2009)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "MaCI_EmergencyStop_GUI.h"

///////////////////////////////////////////////////////////////////////////

MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	m_menubar1 = new wxMenuBar( 0 );
	m_menu_File = new wxMenu();
	wxMenuItem* m_menuItem_Quit;
	m_menuItem_Quit = new wxMenuItem( m_menu_File, wxID_ANY, wxString( wxT("&Quit") ) , wxEmptyString, wxITEM_NORMAL );
	m_menu_File->Append( m_menuItem_Quit );
	
	m_menubar1->Append( m_menu_File, wxT("&File") );
	
	m_menu2 = new wxMenu();
	wxMenuItem* m_menuItem3;
	m_menuItem3 = new wxMenuItem( m_menu2, wxID_ANY, wxString( wxT("&HowTo...") ) , wxEmptyString, wxITEM_NORMAL );
	m_menu2->Append( m_menuItem3 );
	
	wxMenuItem* m_menuItem2;
	m_menuItem2 = new wxMenuItem( m_menu2, wxID_ANY, wxString( wxT("&About...") ) , wxEmptyString, wxITEM_NORMAL );
	m_menu2->Append( m_menuItem2 );
	
	m_menubar1->Append( m_menu2, wxT("&Help") );
	
	this->SetMenuBar( m_menubar1 );
	
	wxBoxSizer* bSizer1;
	bSizer1 = new wxBoxSizer( wxVERTICAL );
	
	wxBoxSizer* bSizer3;
	bSizer3 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText_Connection = new wxStaticText( this, wxID_ANY, wxT("Not Connected"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
	m_staticText_Connection->Wrap( -1 );
	bSizer3->Add( m_staticText_Connection, 0, wxALL|wxEXPAND, 5 );
	
	m_staticText_target = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
	m_staticText_target->Wrap( -1 );
	bSizer3->Add( m_staticText_target, 0, wxALL|wxEXPAND, 5 );
	
	bSizer1->Add( bSizer3, 0, wxEXPAND, 5 );
	
	wxBoxSizer* bSizer2;
	bSizer2 = new wxBoxSizer( wxVERTICAL );
	
	wxBoxSizer* bSizer4;
	bSizer4 = new wxBoxSizer( wxVERTICAL );
	
	m_bpButton_EmergencyStop = new wxBitmapButton( this, wxID_ANY, wxBitmap( wxT("Stop.bmp"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxSize( 200,200 ), wxBU_AUTODRAW );
	
	m_bpButton_EmergencyStop->SetBitmapSelected( wxBitmap( wxT("Stopped.bmp"), wxBITMAP_TYPE_ANY ) );
	m_bpButton_EmergencyStop->SetBackgroundColour( wxColour( 255, 255, 0 ) );
	
	m_bpButton_EmergencyStop->SetBackgroundColour( wxColour( 255, 255, 0 ) );
	
	bSizer4->Add( m_bpButton_EmergencyStop, 0, wxALIGN_CENTER|wxALL, 5 );
	
	m_button_Deactivate = new wxButton( this, wxID_ANY, wxT("Deactivate"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer4->Add( m_button_Deactivate, 0, wxALIGN_CENTER|wxALL, 5 );
	
	m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	bSizer4->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
	
	bSizer2->Add( bSizer4, 1, wxEXPAND, 5 );
	
	bSizer1->Add( bSizer2, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bSizer5;
	bSizer5 = new wxBoxSizer( wxHORIZONTAL );
	
	m_button1 = new wxButton( this, wxID_ANY, wxT("Bind key to emergency stop"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer5->Add( m_button1, 1, wxALIGN_CENTER|wxALL|wxRIGHT, 5 );
	
	m_button5 = new wxButton( this, wxID_ANY, wxT("Test"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer5->Add( m_button5, 0, wxALL|wxLEFT, 5 );
	
	bSizer1->Add( bSizer5, 0, wxEXPAND, 5 );
	
	this->SetSizer( bSizer1 );
	this->Layout();
	
	// Connect Events
	this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrame::OnClose ) );
	this->Connect( m_menuItem_Quit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnQuit ) );
	this->Connect( m_menuItem3->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnHowTo ) );
	this->Connect( m_menuItem2->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnAbout ) );
	m_bpButton_EmergencyStop->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnEmergencyStopClicked ), NULL, this );
	m_button_Deactivate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnDeactivate ), NULL, this );
	m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnKeyBind ), NULL, this );
	m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnTestButtonClicked ), NULL, this );
}

MainFrame::~MainFrame()
{
	// Disconnect Events
	this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrame::OnClose ) );
	this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnQuit ) );
	this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnHowTo ) );
	this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnAbout ) );
	m_bpButton_EmergencyStop->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnEmergencyStopClicked ), NULL, this );
	m_button_Deactivate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnDeactivate ), NULL, this );
	m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnKeyBind ), NULL, this );
	m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::OnTestButtonClicked ), NULL, this );
}

DeactivationDialog::DeactivationDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	wxBoxSizer* bSizer6;
	bSizer6 = new wxBoxSizer( wxVERTICAL );
	
	wxBoxSizer* bSizer7;
	bSizer7 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText_Question = new wxStaticText( this, wxID_ANY, wxT("Are you really sure to deactivate emergency stop from:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText_Question->Wrap( -1 );
	bSizer7->Add( m_staticText_Question, 0, wxALL, 5 );
	
	m_staticText_from = new wxStaticText( this, wxID_ANY, wxT("'Unknown'"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText_from->Wrap( -1 );
	bSizer7->Add( m_staticText_from, 0, wxALL, 5 );
	
	bSizer6->Add( bSizer7, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bSizer8;
	bSizer8 = new wxBoxSizer( wxHORIZONTAL );
	
	m_button3 = new wxButton( this, wxID_ANY, wxT("yes"), wxDefaultPosition, wxSize( 30,30 ), 0 );
	bSizer8->Add( m_button3, 0, wxALL, 5 );
	
	m_button5 = new wxButton( this, wxID_ANY, wxT("NO"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer8->Add( m_button5, 1, wxALL, 5 );
	
	bSizer6->Add( bSizer8, 1, wxEXPAND, 5 );
	
	this->SetSizer( bSizer6 );
	this->Layout();
	bSizer6->Fit( this );
	
	// Connect Events
	m_button3->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DeactivationDialog::OnYesClicked ), NULL, this );
	m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DeactivationDialog::OnNoClicked ), NULL, this );
}

DeactivationDialog::~DeactivationDialog()
{
	// Disconnect Events
	m_button3->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DeactivationDialog::OnYesClicked ), NULL, this );
	m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DeactivationDialog::OnNoClicked ), NULL, this );
}

About_Dialog::About_Dialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	wxBoxSizer* bSizer15;
	bSizer15 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText3 = new wxStaticText( this, wxID_ANY, wxT("MaCI Emergency stop - Gimbo Component"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText3->Wrap( -1 );
	m_staticText3->SetFont( wxFont( 16, 70, 90, 92, false, wxEmptyString ) );
	
	bSizer15->Add( m_staticText3, 0, wxALIGN_CENTER|wxALL, 5 );
	
	m_staticText_Version = new wxStaticText( this, wxID_ANY, wxT("Version 0.01 beta"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText_Version->Wrap( -1 );
	bSizer15->Add( m_staticText_Version, 0, wxALIGN_CENTER|wxALL, 5 );
	
	m_staticText5 = new wxStaticText( this, wxID_ANY, wxT("by"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText5->Wrap( -1 );
	bSizer15->Add( m_staticText5, 0, wxALIGN_CENTER|wxALL, 5 );
	
	m_staticText6 = new wxStaticText( this, wxID_ANY, wxT("Matthieu Myrsky <matthieu.myrsky@tkk.fi>"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText6->Wrap( -1 );
	m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	bSizer15->Add( m_staticText6, 0, wxALIGN_CENTER|wxALL, 5 );
	
	m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	bSizer15->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 );
	
	m_button8 = new wxButton( this, wxID_ANY, wxT("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer15->Add( m_button8, 0, wxALIGN_CENTER|wxALL, 5 );
	
	this->SetSizer( bSizer15 );
	this->Layout();
	bSizer15->Fit( this );
	
	// Connect Events
	m_button8->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( About_Dialog::OnOk ), NULL, this );
}

About_Dialog::~About_Dialog()
{
	// Disconnect Events
	m_button8->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( About_Dialog::OnOk ), NULL, this );
}

Information_Dialog::Information_Dialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	wxBoxSizer* bSizer10;
	bSizer10 = new wxBoxSizer( wxVERTICAL );
	
	wxBoxSizer* bSizer11;
	bSizer11 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText_info = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 300,150 ), 0 );
	m_staticText_info->Wrap( 280 );
	bSizer11->Add( m_staticText_info, 0, wxALL|wxEXPAND, 5 );
	
	bSizer10->Add( bSizer11, 1, wxEXPAND, 5 );
	
	this->SetSizer( bSizer10 );
	this->Layout();
	bSizer10->Fit( this );
}

Information_Dialog::~Information_Dialog()
{
}

Help_Dialog::Help_Dialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	wxBoxSizer* bSizer14;
	bSizer14 = new wxBoxSizer( wxVERTICAL );
	
	m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
	m_panel1 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	wxBoxSizer* bSizer15;
	bSizer15 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText11 = new wxStaticText( m_panel1, wxID_ANY, wxT("Usage with keyboard:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText11->Wrap( -1 );
	m_staticText11->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	bSizer15->Add( m_staticText11, 0, wxALL, 5 );
	
	m_staticText13 = new wxStaticText( m_panel1, wxID_ANY, wxT("(NOTE: This module must be compiled with sudo rights to use it with keyboard)"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText13->Wrap( -1 );
	m_staticText13->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 93, 90, false, wxEmptyString ) );
	
	bSizer15->Add( m_staticText13, 0, wxALL, 5 );
	
	m_staticText14 = new wxStaticText( m_panel1, wxID_ANY, wxT("1. Bind key with 'Bind key to emergency stop'- button"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText14->Wrap( -1 );
	bSizer15->Add( m_staticText14, 0, wxALL, 5 );
	
	m_staticText15 = new wxStaticText( m_panel1, wxID_ANY, wxT("2. To activate emergency stop:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText15->Wrap( -1 );
	m_staticText15->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, true, wxEmptyString ) );
	
	bSizer15->Add( m_staticText15, 0, wxALL, 5 );
	
	m_staticText16 = new wxStaticText( m_panel1, wxID_ANY, wxT("    Press the binded key and activate emergency stop, even if the window hasn't focus."), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText16->Wrap( 480 );
	bSizer15->Add( m_staticText16, 0, wxALL, 5 );
	
	m_staticText35 = new wxStaticText( m_panel1, wxID_ANY, wxT("  OR"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText35->Wrap( -1 );
	bSizer15->Add( m_staticText35, 0, wxALL, 5 );
	
	m_staticText17 = new wxStaticText( m_panel1, wxID_ANY, wxT("    Click the big red button with yellow background with your mouse."), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText17->Wrap( 480 );
	bSizer15->Add( m_staticText17, 0, wxALL, 5 );
	
	m_staticText18 = new wxStaticText( m_panel1, wxID_ANY, wxT("3. To deactivate emergency stop"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText18->Wrap( -1 );
	bSizer15->Add( m_staticText18, 0, wxALL, 5 );
	
	m_staticText121 = new wxStaticText( m_panel1, wxID_ANY, wxT("  Click 'deactivate'-button and answer yes."), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText121->Wrap( 480 );
	bSizer15->Add( m_staticText121, 0, wxALL, 5 );
	
	m_panel1->SetSizer( bSizer15 );
	m_panel1->Layout();
	bSizer15->Fit( m_panel1 );
	m_notebook1->AddPage( m_panel1, wxT("Keyboard"), false );
	m_panel2 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	wxBoxSizer* bSizer151;
	bSizer151 = new wxBoxSizer( wxVERTICAL );
	
	m_staticText20 = new wxStaticText( m_panel2, wxID_ANY, wxT("Usage with USB \"Panic button\""), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText20->Wrap( -1 );
	m_staticText20->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	bSizer151->Add( m_staticText20, 0, wxALL, 5 );
	
	m_staticText131 = new wxStaticText( m_panel2, wxID_ANY, wxT("(NOTE: This module must be compiled with sudo rights to use it with USB Panic button)"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText131->Wrap( 480 );
	m_staticText131->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 93, 90, false, wxEmptyString ) );
	
	bSizer151->Add( m_staticText131, 0, wxALL, 5 );
	
	m_staticText21 = new wxStaticText( m_panel2, wxID_ANY, wxT("1. USB Panic button is automatically searched when launching MaCI_EmergencyStop module"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText21->Wrap( 480 );
	m_staticText21->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	bSizer151->Add( m_staticText21, 0, wxALL, 5 );
	
	m_staticText28 = new wxStaticText( m_panel2, wxID_ANY, wxT("2 If Panic button found:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText28->Wrap( -1 );
	m_staticText28->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	bSizer151->Add( m_staticText28, 0, wxALL, 5 );
	
	m_staticText22 = new wxStaticText( m_panel2, wxID_ANY, wxT("  2.1. Just press the button to activate Emergency stop"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText22->Wrap( -1 );
	bSizer151->Add( m_staticText22, 0, wxALL, 5 );
	
	m_staticText29 = new wxStaticText( m_panel2, wxID_ANY, wxT("3. If not found:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText29->Wrap( -1 );
	m_staticText29->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
	
	bSizer151->Add( m_staticText29, 0, wxALL, 5 );
	
	m_staticText341 = new wxStaticText( m_panel2, wxID_ANY, wxT("  3.1 run as root script named unbind_usbhid : 'sudo ./unbind_usbhid'"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText341->Wrap( -1 );
	bSizer151->Add( m_staticText341, 0, wxALL, 5 );
	
	m_staticText34 = new wxStaticText( m_panel2, wxID_ANY, wxT("  3.2 Restart this component"), wxDefaultPosition, wxDefaultSize, 0 );
	m_staticText34->Wrap( -1 );
	bSizer151->Add( m_staticText34, 0, wxALL, 5 );
	
	m_panel2->SetSizer( bSizer151 );
	m_panel2->Layout();
	bSizer151->Fit( m_panel2 );
	m_notebook1->AddPage( m_panel2, wxT("USB Panic Button"), true );
	
	bSizer14->Add( m_notebook1, 10, wxEXPAND | wxALL, 5 );
	
	m_button91 = new wxButton( this, wxID_ANY, wxT("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer14->Add( m_button91, 1, wxALIGN_CENTER|wxALL, 5 );
	
	this->SetSizer( bSizer14 );
	this->Layout();
	
	// Connect Events
	m_button91->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Help_Dialog::OnOk ), NULL, this );
}

Help_Dialog::~Help_Dialog()
{
	// Disconnect Events
	m_button91->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( Help_Dialog::OnOk ), NULL, this );
}
